package com.lensong.plugin.sentinel.util;

import org.apache.http.HttpResponse;
import org.apache.http.Header;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.HttpClients;

import java.io.IOException;

/**
 * Copyright （c）. All rights reserved.
 *
 * @author len.song
 * @date 2022/04/07
 */
public class HttpUtils {
    public static HttpResponse doPost(HttpPost post) throws IOException {
        HttpClient httpclient = HttpClients.createDefault();
        post.addHeader("Content-Type", "application/x-protobuf");
        post.addHeader("Accept", "application/x-protobuf");
        for (Header header : post.getAllHeaders()) {
            System.out.println(header.getName() + ":" + header.getValue());
        }
        return httpclient.execute(post);
    }

}
